package Hot150;

import java.util.Arrays;

public class hIndex {
    public static void main(String[] args) {
        int[] citations = {11,15};
        System.out.println(new hIndex().hIndex(citations));
    }
    public int hIndex(int[] citations) {
        int max = 0;
        int result = citations.length;
        while(true){
            int can = citations.length - result;
            for (int i = 0; i < citations.length; i++) {
                if(citations[i] < result){
                    can --;
                }
                if(can < 0){
                    result --;
                    break;
                }
            }
            if(can >= 0){
                return result;
            }
        }
    }
}
